<?php

namespace App\Http\Controllers\Admin\OrdersRemark;

use App\Http\Controllers\Controller as BaseController;
use App\Repository\Orders\OrdersRemarkRepository;
use Illuminate\Http\Request;

// 订单备注
class IndexController extends BaseController
{
    private $repoist;

    public function __construct(OrdersRemarkRepository $repository)
    {
        $this->repoist = $repository;
    }

    public function add(Request $request)
    {
        if (!$request->get('orders_id')) {
            return $this->returnMsg(1, '请传递定单id参数');
        }
        if (empty($request->get('remark'))) {
            return $this->returnMsg(1, '备注信息不能为空');
        }
        $request->merge(['users_id' => $request->user->id]);
//        print_r($request->get('users_id'));
        return $this->repoist->unifiedAdd($request);
    }

//   列表指定单的备注信息
    public function remarkLogs(Request $request)
    {
        if (!$request->get('orders_id')) {
            return $this->returnMsg(1, '请传递定单id参数');
        }
        return $this->repoist->remarkLogs($request->get("orders_id"), $request->get("pageNum"), $request->get("pageSize"));
    }
}
